#include<bits/stdc++.h>
using namespace std;
struct node{
    int l,r;
}t[100010];
int T,m,n,L,V,xx,ans=0;
int flag[100010],cs[100010],d[100010],v[100010],a[100010];
double vv;
bool cmp(node x,node y){
    if(x.r<y.r)return 1;
    else if(x.r==y.r&&x.l>y.l)return 1;
    return 0;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T>0){
        T--;
        memset(flag,0,sizeof(flag));
        memset(t,0,sizeof(t));
        ans=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>flag[i];
        }
        for(int i=1;i<=n;i++){
            bool fl=0;
            if(a[i]>=0){
                int ll=d[i],rr=L;
                for(int j=1;j<=m;j++){
                    if(ll<=flag[j]&&rr>=flag[j]){
                        vv=sqrt(v[i]*v[i]+2*a[i]*(flag[j]-ll));
                        if(vv>V){
                            fl=1;
                            if(t[i].l==0)t[i].l=j;
                            break;
                        }
                    }
                }
                if(fl)t[i].r=m;
            }
            else{
                int ll=d[i],rr=min(L,d[i]+(-v[i]*v[i])/(2*a[i]));
                for(int j=1;j<=m;j++){
                    if(ll<=flag[j]&&rr>=flag[j]){
                        vv=sqrt(v[i]*v[i]+2*a[i]*(flag[j]-ll));
                        if(vv>V){
                            fl=1;
                            if(t[i].l==0)t[i].l=j;
                            t[i].r=j;
                        }
                    }
                }
            }
            if(fl){
                ans++;
            }
        }

        sort(t+1,t+1+n,cmp);
        int rr=0,anss=0;
        for(int i=1;i<=n;i++){
            if(rr>=t[i].l)continue;
            anss++;
            rr=t[i].r;
            //cout<<"check:"<<t[i].r<<endl;
        }
        cout<<ans<<" ";
        cout<<m-anss<<endl;
    }
    return 0;
}
